package com.example.androidgame;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {
	private static final String SOAP_ACTION = "http://ws.mkyong.com/getHelloWorldAsString";
	private static final String METHOD_NAME = "getHelloWorldAsString";
	private static final String NAMESPACE = "http://ws.mkyong.com/";
	private static final String URL = "http://10.0.2.2:8080/ws/hello?wsdl";

	/** Called when the activity is first created. */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);           
		 
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	         
	        envelope.setOutputSoapObject(request);
	 
	        HttpTransportSE ht = new HttpTransportSE(URL);
	        try {
	         ht.call(SOAP_ACTION, envelope);
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	             
	            TextView tv = new TextView(this);
	            tv.setText("Message :"+response.toString());
	            setContentView(tv);
	   
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
